<template>
<div class="postmsg">
    <el-row>
        <el-col :xs="18" :sm="18" :md="18" :lg="18" :xl="18">
            <el-form :model="LandParcelInfo" ref="ruleForm" label-width="140px" :disabled="!type" class="demo-ruleForm">
                <el-form-item label="图斑ID">
                    <el-input ref="landCode" v-model="LandParcelInfo.landCode" :disabled="true">
                    </el-input>
                </el-form-item>

                <el-form-item label="地塘块命名">
                    <el-input v-model="LandParcelInfo.landName" :disabled="true"></el-input>
                </el-form-item>

                <el-form-item label="镇街">
                    <el-select  style="width: 100%" v-model="LandParcelInfo.landTownCode" placeholder="请选择" @change="townChange">
                        <el-option v-for="(item, itemIndex) in town" :key="itemIndex" :label="item.label" :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="村居">
                    <el-select  style="width: 100%" v-model="LandParcelInfo.landVillageCode" placeholder="请选择">
                        <el-option v-for="(itemChildren, ChildrenIndex) in villager" :key="ChildrenIndex" :label="itemChildren.label" :value="itemChildren.value">
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="村小组/经济社">
                    <el-input  v-model="LandParcelInfo.landStatusQuo"></el-input>
                </el-form-item>

                <el-form-item label="大棚">
                  <el-checkbox v-model="LandParcelInfo.isLargeGreenhouse">{{LandParcelInfo.isLargeGreenhouse?'有':'无'}}</el-checkbox>
                </el-form-item>

                <el-form-item label="土地性质">
                    <el-input :disabled="true"  v-model="LandParcelInfo.landProduce" placeholder="没有数据源"></el-input>
                </el-form-item>


                <el-form-item label="土地现状">
                    <el-cascader :disabled="true" :props="{ checkStrictly: true }"  v-model="LandParcelInfo.landType" :options="cascaderOptionsOne" @change="handleChange" style="width: 100% !important">
                    </el-cascader>
                </el-form-item>



                <el-form-item label="农产品分类">
                    <el-cascader :props="{ checkStrictly: true }"  v-model="LandParcelInfo.landProduct" :options="cascaderOptionsTwo" filterable @change="handleChangeTwo" style="width: 100% !important">
                    </el-cascader>
                </el-form-item>

       
 

          
                <el-form-item label="品种">
                    <el-input  v-model="LandParcelInfo.landOtherType"></el-input>
                </el-form-item>
                <el-form-item label="作物" style="display:none">
                    <el-input  v-model="LandParcelInfo.landProduce"></el-input>
                </el-form-item>

                <el-form-item label="年产量">
                    <el-input style="width:70%" required  v-model="LandParcelInfo.landYearOutput">
                    </el-input>
                    <el-select style="width:30%" v-model="LandParcelInfo.landOutputUnit" placeholder="请选择">
                        <el-option v-for="item in landOutputUnit" :key="item.value" :label="item.label" :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="面积（亩）">
                    <el-input :disabled="true" v-model="LandParcelInfo.landProductArea"></el-input>
                </el-form-item>
        
                <el-form-item v-if="LandParcelInfo.XY" label="地块坐标">
                    <el-input :readonly="true"  v-model="LandParcelInfo.XY">
                        <template slot="append">
                            <el-button type="primary" @click="location(LandParcelInfo.XY)">定位</el-button>
                        </template>
                    </el-input>

                </el-form-item>

                <el-form-item label="备注" style="display: none">
                    <el-input type="textarea" :readonly="true"  v-model="LandParcelInfo.textarea"></el-input>
                </el-form-item>

            </el-form>
        </el-col>
        <el-col :xs="4" :sm="4" :md="4" :lg="4" :xl="4">
            <div class="img">
                <Avatar @click="getImgUrl" :headUrl="ossImgList">图片上传</Avatar>
            </div>
            <!--                <el-image style="width: 220px; height: 220px; border: 2px solid #EEEEEE; border-radius: 5px;" :src="ossImgList"  v-else></el-image>-->
        </el-col>
    </el-row>

    <el-row>
        <el-col :span="24">
            <el-card>
                <div slot="header" class="flex">
                    <span>所属主体</span>
                    <div>
                        <relevancy style="float: right" @on-success="getSubject" :landCodeT="landCodeT" v-if="type" @click.native="getLandCodeT">新增主体</relevancy>
                    </div>
                </div>
                <el-table :data="subjectData" border style="width: 100%">
                    <el-table-column prop="subjectName" label="主体名称" width="180">
                    </el-table-column>
                    <el-table-column prop="subjectBase" label="基地/土名" width="180">
                    </el-table-column>
                    <el-table-column prop="lsSubjectUseArea" label="占地面积（亩）">
                    </el-table-column>
                    <el-table-column prop="lsYearValue" label="年产值(万元)">
                    </el-table-column>
                    <el-table-column prop="contractStartTime" label="承包开始时间">
                    </el-table-column>
                    <el-table-column prop="contractEndTime" label="承包结束时间">
                    </el-table-column>
                    <el-table-column prop="contractYear" label="承包年限">
                    </el-table-column>
                    <el-table-column prop="address" label="操作" v-if="type">
                        <template slot-scope="scope">
                            <el-link type="primary" style="margin-right: 20px" @click="editShow(scope.row)">编辑</el-link>
                            <el-link type="primary" @click="deleteSubject(scope.row)">删除</el-link>
                        </template>
                    </el-table-column>
                </el-table>
            </el-card>
        </el-col>
    </el-row>

    <el-row v-if="type" style="margin-top: 25px;">
        <el-col>
            <el-card>
                <el-row>
                    <el-col :span="12">
                        <div class="blueColor">更新信息</div>
                        <div style="margin-top: 20px">
                            <span>更新时间：</span><span>{{ details.updateTime }}</span>
                        </div>
                        <div style="margin-top: 6px">
                            <span>更新人：</span><span>{{ details.updatePerson }}</span>
                        </div>
                    </el-col>
                    <el-col :span="12">
                        <div>
                            <span class="blueColor">审核信息</span>
                            <el-button type="primary" style="margin-left: 20px" size="mini" @click="audit()" v-if="userInfo.userLevel < 5">审核</el-button>
                        </div>
                        <div style="margin-top: 20px">
                            <span>审核提交时间：</span><span>{{ details.auditDate }}</span>
                        </div>
                        <div style="margin-top: 6px">
                            <span>审核人：</span><span>{{ details.auditPerson }}</span>
                        </div>
                        <div style="margin-top: 6px">
                            <span>审核状态：</span><span>{{ auditStatusCn(details.auditStatus) }}</span>
                        </div>
                        <div style="margin-top: 6px">
                            <span>审核意见：</span><span>{{ details.auditMemo }}</span>
                        </div>
                    </el-col>
                </el-row>

         

            </el-card>
            <el-button type="primary" style="margin:30px auto;display: block;" @click="editLand()">提交采集信息</el-button>
        </el-col>
    </el-row>

    <el-dialog title="修改主体" :append-to-body="true" label-width="100px" :visible.sync="editSubjectShow">
        <el-form :model="form">
            <el-form-item label="经营主体">
                <el-input v-model="form.subjectName" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="占用面积（亩）">
                <el-input v-model="form.lsSubjectUseArea" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="年产值(万元)">
                <el-input v-model="form.lsYearValue" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="承包周期">
                <el-date-picker v-model="form.date" type="daterange" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="承包年限">
                <el-input v-model="form.contractYear" autocomplete="off"></el-input>
            </el-form-item>

            <el-form-item label="所属基地">
                <el-input v-model="form.subjectBase" :disabled="true"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="editSubjectShow = false">取 消</el-button>
            <el-button type="primary" @click="updateSubject()">确 定</el-button>
        </div>
    </el-dialog>
    <!--    <el-dialog title="图斑地块审核" :append-to-body="true" :visible.sync="dialogStatus" :close-on-click-modal="false" width="40%" :destroy-on-close="true">-->
    <!--        <el-form :model="details" status-icon ref="modelData" :inline="false" size="normal" label-width="90px" label-position="right">-->
    <!--            <el-row>-->
    <!--                <el-col :span="24">-->
    <!--                    <main class="userdata">-->
    <!--                        <p>图斑ID: {{ details.landCode }}</p>-->
    <!--                        <p>地块名: {{ details.landName }}</p>-->
    <!--                        <p>镇名: {{ details.landTownName }}</p>-->
    <!--                        <p>村名: {{ details.landVillageName }}</p>-->
    <!--                    </main>-->
    <!--                    <el-form-item label="审核状态" prop="name">-->
    <!--                        <el-input v-model="details.auditStatus"> </el-input>-->
    <!--                        <template>-->
    <!--                            <el-radio v-model="details.auditStatus" :label="2">通过</el-radio>-->
    <!--                            <el-radio v-model="details.auditStatus" :label="3">不通过</el-radio>-->
    <!--                        </template>-->
    <!--                    </el-form-item>-->
    <!--                    <el-form-item label="审核描述" prop="name">-->
    <!--                        <el-input type="textarea" v-model="details.auditMemo">-->
    <!--                        </el-input>-->
    <!--                    </el-form-item>-->
    <!--                </el-col>-->
    <!--            </el-row>-->
    <!--        </el-form>-->
    <!--        <span slot="footer" class="dialog-footer">-->
    <!--                    <el-button type="primary" size="mini" @click="onSubmit()">确 定</el-button>-->
    <!--                </span>-->
    <!--    </el-dialog>-->

    <el-dialog title="图斑地块审核" :visible.sync="dialogStatus" :close-on-click-modal="false" width="30%" :append-to-body="true" :destroy-on-close="true">
        <el-form :model="details" status-icon ref="modelData" :inline="false" size="normal" label-width="90px" label-position="right">
            <el-form-item label="图斑ID" prop="landCode">
                <el-input disabled type="text" v-model="details.landId"> </el-input>
            </el-form-item>
            <el-form-item label="地块名" prop="landName">
                <el-input disabled type="text" v-model="details.landName"> </el-input>
            </el-form-item>
            <el-form-item label="地块面积(亩)" prop="landArea">
                <el-input disabled type="text" v-model="details.landProductArea"> </el-input>
            </el-form-item>
            <el-form-item label="镇名" prop="landTownName">
                <el-input disabled type="text" v-model="details.landTownName">
                </el-input>
            </el-form-item>
            <el-form-item label="村名" prop="landVillageName">
                <el-input disabled type="text" v-model="details.landVillageName">
                </el-input>
            </el-form-item>
            <el-form-item label="审核状态" prop="name">
                <el-radio v-model="details.auditStatus" :label="2">通过</el-radio>
                <el-radio v-model="details.auditStatus" :label="3">不通过</el-radio>
            </el-form-item>
            <el-form-item label="审核描述" prop="name">
                <el-input type="textarea" v-model="details.auditMemo"> </el-input>
            </el-form-item>
        </el-form>

        <span slot="footer" class="dialog-footer">
            <el-button type="primary" size="mini" @click="onSubmit()">确 定</el-button>
        </span>
    </el-dialog>
</div>
</template>

<script>
import {
    mapState,
    mapGetters
} from "vuex";
import {
    convertKey,
    formatDate
} from "@/library";
import addSubject from "./addSubject/addSubject";
import relevancy from "./relevancy/relevancy";

export default {
    props: {
        appendtobody: {
            type: Boolean,
            default: false,
        },
        LandParcelInfo: {
            type: Object,
            default: function () {
                return {};
            },
        },
        LandParcelInfoVisible: {
            type: Boolean,
            default: false,
        },
        subjectData: {
            type: Array,
            default: function () {
                return [];
            },
        },
        type: {
            type: Boolean,
            default: false,
        },
    },
    components: {
        addSubject,
        relevancy,
    },
    name: "PlotMsg",
    data() {
        return {
            pickerOptions: {
                shortcuts: [{
                        text: "最近一年",
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90 * 4);
                            picker.$emit("pick", [start, end]);
                        },
                    },
                    {
                        text: "最近三年",
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90 * 12);
                            picker.$emit("pick", [start, end]);
                        },
                    },
                ],
            },

            addSubjectShow: false,
            dialogStatus: false,
            details: {
                updateTime: "",
                updatePerson: "",
                auditDate: "",
                auditPerson: "",
                auditMemo: "",
                auditStatus: 0,
                auditStatusName: "",
                landIds: "",
                landProductArea:""
            },
            avatarUrl: require("@/assets/404.jpg"),
            form: {
                subjectName: "",
            },
            editSubjectShow: false,
            landCodeT: "",
            currentTownInfo: "",
            currentVillagerInfo: "",
            currentTownCode: "",
            currentVillagerCode: "",
            tableData: [],
            ruleForm: {},
            tabPosition: "left",
            id: "",
            towns: "",
            village: "",
            auditDate: "2021-04-22 02:00:19",
            canEdit: true,
            editBtn: "修改",
            filtersVillage: [],
            villagerIndex: 0,
            cascaderOptionsOne: [],
            cascaderOptionsTwo: [],
            landOutputUnit: {},
            subjectDataEmit: null,
        };
    },
    created() {
        this.$set(this.LandParcelInfo, 'textarea', '')
        if (this.LandParcelInfo.landCode) {
            this.landCodeT = this.LandParcelInfo.landCode;
        }

        // console.log(this.options)
        // fetch("/getTreeData.json")
        //   .then((res) => res.json())
        //   .then((res) => {
        //     this.filtersVillage = JSON.parse(
        //       JSON.stringify(res.data.treeItem, [
        //         "administrativeName",
        //         "administrativeCode",
        //         "children",
        //       ])
        //     );
        //     this.filtersVillage = convertKey(this.filtersVillage, {
        //       administrativeName: "label",
        //       administrativeCode: "value",
        //     });
        //     console.log(this.filtersVillage)
        //   });

        // this.reloadSubject();
        this.getLandTypeList();
        this.getLandProductList();
        this.propertyValue();
    },
    computed: {
        naming() {
            return 1;
        },
        town() {
            return this.options;
        },
        villager: {
            get() {
                return this.options[this.villagerIndex].children;
            },
            set(index) {
                this.villagerIndex = index;
            },
        },
        ossImgList() {
            // LandParcelInfo.ossImgList != null && LandParcelInfo.ossImgList != '' ? LandParcelInfo.ossImgList[0].imgUrl : avatarUrl
            // console.log(this.LandParcelInfo.ossImgList != null && this.LandParcelInfo.ossImgList != '')
            if (
                this.LandParcelInfo.ossImgList != null &&
                this.LandParcelInfo.ossImgList != ""
            ) {
                return this.LandParcelInfo.ossImgList[0].imgUrl;
            } else {
                return this.avatarUrl;
            }
        },
        ...mapGetters({
            options: "getTreeData/filtersVillage",
        }),
        //修改图斑时需要的数据
        sendChange() {
            return {
                villagerIndex: 0,
                //地块id Long
                landId: "62",
                //地块编号 String
                landCode: "测试",
                //地块名字 String
                landName: "测试",
                //地块面积 double
                landArea: "66.66",
                //地块类型 int
                landType: [],
                //其他类型 String
                landOtherType: "测试",
                //年产量 double
                landProductArea: "66.66",
                //生产面积 double
                landYearOutput: "100",
                //产量单位 int
                landOutputUnit: "100",
                //产品类别 int
                landProduct: "1",
                //地产值 double
                landYearValue: "100.11",
                //计划编号 Long
                landPlanId: "123",
                //地块备注 String
                landMemo: "sss",
                //镇 Long
                landTownId: "1",
                //村 Long
                landVillageId: "1",
                //创建人 String
                createPerson: "测试",
                //更新人 String
                updatePerson: "测试",
                //审核人 String
                auditPerson: "2021-04-22 02:00:19",
                //审核时间 Date
            };
        },
        ...mapState({
            model: (state) => state.Map.model,
            userInfo: (state) => {
                return state.User.userInfo;
            },
        }),
    },
    methods: {
        changeisLargeGreenhouse(e) {
            console.log(e);
        },
        getLandCodeT() {
            if (this.LandParcelInfo.landCode) {
                this.landCodeT = this.LandParcelInfo.landCode;
            }
        },
        location(xy) {
            this.$alert("此操作会关闭当前界面回到地图界面", "图斑定位", {
                showCancelButton: true,
            }).then((e) => {
                this.$emit("on-location", xy);
            });
        },
        getSubject(subjectArray) {
            subjectArray.forEach((item) => {
                this.subjectData.push(item);
            });
        },
        onSubmit() {
            this.dialogStatus = false;
            this.$confirm("是否确认操作?", "提示", {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    type: "warning",
                })
                .then(() => {
                    //发送审核请求
                    this.$axios
                        .post("rbac/LandSubject/auditLand", {
                            params: {
                                landIds: this.details.id,
                                auditStatus: this.details.auditStatus,
                                auditMemo: this.details.auditMemo,
                            },
                        })
                        .then((result) => {
                            this.$message.success("操作完成");
                            this.getCollectTaskLandList();
                        });
                })
                .catch(() => {});
        },
        auditStatusCn(index) {
            let Status = {
                0: "初始状态",
                1: "待审核",
                2: "审核通过",
                3: "审核失败",
            };
            return Status[index];
        },
        audit() {
            this.dialogStatus = true;
        },
        getCollectTaskLandList() {
            let params = {
                "landInfo.landCode": this.LandParcelInfo.landCode,
                systemTypes: localStorage.getItem("SYS_TYPE"),
                "collectTaskLand.planId": JSON.parse(
                    localStorage.getItem("currentTask/setCurrentTask")
                ).data.id,
            };
            this.$axios
                .get("/rbac/data/CollectTaskLand/list", {
                    params: params,
                })
                .then((res) => {
                    setTimeout(() => {
                        this.details.landIds = this.LandParcelInfo.landCode;
                        this.details = res.data.list[0];
                    }, 300)

                    // this.details.updateTime = res.data.list[0].updateTime ? res.data.list[0].updateTime : '暂无';
                    // this.details.updatePerson = res.data.list[0].updatePerson ? res.data.list[0].updatePerson : '暂无';
                    // this.details.auditDate = res.data.list[0].auditDate ? res.data.list[0].auditDate : '暂无';
                    // this.details.auditStatus = res.data.list[0].auditStatus;
                    // this.details.auditStatusName = res.data.list[0].auditStatus == 0 ? '默认' : res.data.list[0].auditStatus == 1 ? '待审核':  res.data.list[0].auditStatus == 2 ? '审核通过' : '失败' ;
                    // this.details.auditPerson = res.data.list[0].auditPerson ? res.data.list[0].auditPerson : '暂无';
                    // this.details.auditMemo = res.data.list[0].auditMemo ? res.data.list[0].auditMemo : '暂无';
                    // this.details.landIds = res.data.list[0].id;
                });
        },
        propertyValue() {
            this.$axios
                .get("/baseinfo/baseInfo/propertyValue/select", {
                    params: {
                        ptCode: "P01",
                    },
                })
                .then((res) => {
                    this.landOutputUnit = convertKey(res.data, {
                        pvCode: "value",
                        propertyValue: "label",
                    });
                });
        },
        handleChange(value) {
            this.LandParcelInfo.landType = value[value.length - 1];
        },
        handleChangeTwo(value) {
            this.LandParcelInfo.landProduct = value[value.length - 1];
        },
        getLandTypeList() {
            this.$axios
                .get("baseinfo/api/v1.0/fishing/landType/selectAll")
                .then((res) => {
                    this.cascaderOptionsOne = convertKey(res.data.list, {
                        landTypeName: "label",
                        landTypeCode: "value",
                    });
                });
        },
        getLandProductList() {
            this.$axios
                .get("baseinfo/api/v1.0/fishing/landTypep/productType/getList")
                .then((res) => {
                    console.log(res);
                    this.cascaderOptionsTwo = convertKey(res.data.list, {
                        productTypeName: "label",
                        productTypeCode: "value",
                    });
                });
        },
        // getLandNameAuto() {
        //     this.$axios
        //         .post("/rbac/data/LandInfoRule/getLandNameAuto", {
        //             params: {
        //                 landId: this.LandParcelInfo.id,
        //                 town: this.LandParcelInfo.landTownName,
        //                 village: this.LandParcelInfo.landVillageName,
        //                 landType: this.LandParcelInfo.landType,
        //             },
        //         })
        //         .then((res) => {
        //             this.LandParcelInfo.landName = res.data;
        //         });
        // },

        getImgUrl(arr) {
            console.log(arr);
            this.LandParcelInfo.imgUrl = arr.join(",");
            console.log(this.LandParcelInfo.imgUrl);
        },
        cancel() {
            this.LandParcelInfoVisible = false;
            this.$emit("landCancelVisiable", false);
        },
        townChange(res) {
            // console.log(res,this.town);
            this.currentVillagerCode = "";
            this.town.forEach((item, index) => {
                if (item.value === res) {
                    // this.villagerIndex = index
                    // this.currentTownCode = item.label;
                    this.LandParcelInfo.landTownCode = item.label
                    // landTownCode
                    // landVillageCode
                    this.villager = index;
                    // this.currentVillagerCode = item.children[0].label;
                    this.LandParcelInfo.landVillageCode = item.children[0].label;
                }
            });
        },
        toAddSubject() {
            this.addSubjectShow = true;
            this.landCodeT = this.LandParcelInfo.landCode;
        },
        reloadSubject() {
            console.log(123);
            this.$axios
                .get("/rbac/data/LandSubject/get", {
                    params: {
                        "landSubject.lsLandCode": this.landCodeT,
                        "landSubject.lsSubjectCode": "",
                    },
                })
                .then((res) => {
                    console.log(res);
                    if (res.data.list.length > 0) {
                        this.subjectData = res.data.list;
                    } else {
                        this.subjectData = [];
                    }
                });
        },
        handleClose(done) {
            if (this.type) {
                this.$confirm("确认关闭?")
                    .then(() => {
                        this.cancel();
                        done();
                    })
                    .catch(() => {
                        this.cancel();
                    });
            } else {
                this.cancel();
            }
        },
        savePlotMsg() {
            this.canEdit = !this.canEdit;
            this.editBtn === "修改" ?
                (this.editBtn = "保存") :
                (this.editBtn = "修改");
        },
        editLand() {
            // this.LandParcelInfo.landTownName = this.currentVillagerCode
            //   this.LandParcelInfo.landVillageName = this.currentTownCode

            //修改地块信息请求
            delete this.LandParcelInfo.landSubjectRs;

            if (
                localStorage.getItem("currentTask/setCurrentTask") &&
                this.$route.name === "Map"
            ) {
                let currentTask = JSON.parse(
                    localStorage.getItem("currentTask/setCurrentTask")
                );
                this.LandParcelInfo.landPlanId = currentTask.data.id;
            }

            if (this.LandParcelInfo.isLargeGreenhouse) {
                this.LandParcelInfo.isLargeGreenhouse = 1
            } else {
                this.LandParcelInfo.isLargeGreenhouse = 0
            }

            this.$axios
                .post("/rbac/data/LandInfo/collect", {
                    params: this.LandParcelInfo,
                })
                .then((res) => {
                    if (res.errorCode === "00000") {
                        this.$message.success("成功提交");
                        this.$emit("reload");
                        this.$emit("landCancelVisiable", false);
                        if (this.LandParcelInfo.isLargeGreenhouse) {
                            this.LandParcelInfo.isLargeGreenhouse = true
                        } else {
                            this.LandParcelInfo.isLargeGreenhouse = false
                        }
                    } else {
                        this.$message.error(res.errorMsg);
                    }
                    this.LandParcelInfoVisible = false;
                    // this.$emit("on-location", this.LandParcelInfo.XY);
                });
        },
        editShow(row) {
            this.form = row;
            this.editSubjectShow = true;
        },
        deleteSubject(row) {
            console.log(row.landSubjectId);
            let params = {
                id: row.landSubjectId,
            };
            this.$axios
                .post("/rbac/data/LandSubject/delete", {
                    params: params,
                })
                .then((res) => {
                    this.reloadSubject();
                });
        },
        updateSubject() {
            //修改主体信息请求
            this.$axios
                .post("rbac/data/subject/updateInfo", {
                    params: {
                        id: this.form.landSubjectId,
                        subjectName: this.form.subjectName,
                        subjectBase: this.form.subjectBase,
                        lsSubjectUseArea: this.form.lsSubjectUseArea,
                        lsYearValue: this.form.lsYearValue,
                        lsLandCode: this.landCodeT,
                        contractStartTime: formatDate(+new Date(this.form.date[0])),
                        contractEndTime: formatDate(+new Date(this.form.date[1])),
                        contractYear: this.form.contractYear,
                    },
                })
                .then((result) => {
                    if (result.errorCode === "00000") {
                        this.$message.success("主体编辑成功");
                    } else {
                        this.$message.warning(result.errorCode);
                    }

                    this.editSubjectShow = false;
                });
        },
    },
    watch: {
        'LandParcelInfo.landCode': {
            handler(n, o) {
                // this.LandParcelInfo = n
                console.log(n);
                if (this.LandParcelInfo.landVillageCode) {
                    this.town.forEach((item, index) => {
                        if (
                            this.LandParcelInfo.landVillageCode.substring(0, 9) === item.value
                        ) {
                            this.LandParcelInfo.landTownCode = item.value;
                            this.villager = index;
                            for (let index = 0; index < item.children.length; index++) {
                                const element = item.children[index];
                                if (element.value === this.LandParcelInfo.landVillageCode) {
                                    this.LandParcelInfo.landVillageCode = element.value;
                                }
                            }
                        }
                    });
                }
                this.getCollectTaskLandList();
                // this.getLandNameAuto()
            },
            deep: true,
            immediate: true,
        },
        // LandParcelInfo() {
        //   console.log(111);
        //   if (this.LandParcelInfo.landVillageCode) {
        //     this.town.forEach((item, index) => {
        //       if (
        //         this.LandParcelInfo.landVillageCode.substring(0, 9) === item.value
        //       ) {
        //         this.currentTownCode = item.value;
        //         this.villager = index;
        //         for (let index = 0; index < item.children.length; index++) {
        //           const element = item.children[index];
        //           if (element.value === this.LandParcelInfo.landVillageCode) {
        //             this.currentVillagerCode = element.value;
        //           }
        //         }
        //       }
        //     });
        //   }
        //   this.getCollectTaskLandList();
        //   // this.getLandNameAuto()
        // },
    },
    mounted() {
        //修改图斑信息
        this.$fishing.setPlotMSG(this.sendChange).then((res) => {});
    },
};
</script>

<style lang="scss">
.postmsg {
    .el-dialog {
        width: 70%;
        min-width: 1000px;
        max-width: 1200px;
    }

    .flex {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .img {
        min-width: 250px;
        width: 100%;
        height: 250px;
    }

    .el-form {
        width: 90%;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        align-items: center;

        >.el-form-item {
            width: 50%;

            >.el-select {
                width: 100%;
            }

            >.el-input {
                width: 100%;
            }
        }
    }

    .column {
        width: 80%;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;

        .btn-block {
            margin-top: 15px;
        }
    }

    .el-input__inner {
        width: 100%;
    }
}

.blueColor {
    color: #1e89eb;
    font-size: 16px;
}
</style>
